<?php

namespace app\index\controller;

use think\facade\Db;
use think\facade\View;

class IndexController extends BaseController {

    // 首页
    public function index() {
        // 轮播图
        $bannerList = Db::name('WebBanner')->select()->toArray();
        // 案例分类
        $cateList = Db::name('WebProductsCategory')->select()->toArray();
        // 案例列表
        $productsList = Db::name('WebProducts')->field('id, products_category_id, title, img_url')->limit(6)->order('sort')->select()->toArray();
        // 新闻推荐列表2条数据
        $newsList = Db::name('WebNews')->field('id, title, img_url, DATE_FORMAT(create_time, "%Y-%m-%d") as create_time, `desc`')->order('sort, create_time desc')->limit(2)->select()->toArray();
        // 新闻列表
        $newsListAll = Db::name('WebNews')->field('id, title, img_url, DATE_FORMAT(create_time, "%Y-%m-%d") as create_time')->order('sort, create_time desc')->limit(2, 6)->select()->toArray();
        // 合作伙伴
        $partnerList = Db::name('WebPartner')->field('id, title, img_url, web_url')->select()->toArray();
        // 解决方案
        $solutionList = Db::name('WebSolution')->field('id, title, `desc`, img_url, icon_url')->order('sort, id desc')->limit(8)->select()->toArray();
        // p($productsList);
        View::assign([
            'bannerList'  => $bannerList,
            'productsList' => $productsList,
            'cateList' => $cateList,
            'newsList' => $newsList,
            'newsListAll' => $newsListAll,
            'partnerList' => $partnerList,
            'solutionList' => $solutionList,
        ]);

        return view();
    }

    // 人才招聘
    public function recruit() {
        return view();
    }

    // 关于艾思
    public function about() {
        return view();
    }
}
